import {defineStore} from "pinia";

export const useTokenStore = defineStore("token", {
    state: () => {
        return {
            token: "",
        }
    },
    actions: {
        setToken(token) {
            this.token = token;
        },
        clearToken() {
            this.token = "";
        }
    },
    persist: {
        enabled: true,
        strategies: [{
            key: "token",
            storage: localStorage,
        }]
    }
});

export const useUserStore = defineStore("user", {
    state: () => {
        return {
            user: {},
        }
    },
    actions: {
        setUser(user) {
            this.user = user;
        },
        clearUser() {
            this.user = {}
        }
    },
    persist: {
        enabled: true,
        strategies: [{
            key: "user",
            storage: localStorage,
        }]
    }
})